﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MM.Domain;
using MM.Contract.Categorias;

namespace MM.Contract.Movies
{
    public class MovieService : IMovieService
    {
        IMovieRepository movieRepository;
        ICategoriaService categoriaService;

        public MovieService(IMovieRepository repository, ICategoriaService categoriaService) {

            this.movieRepository = repository;
            this.categoriaService = categoriaService;
        }

        #region Miembros de IMovieService

        public void AddMovie(Movie movie) {

            movieRepository.MakePersistent(movie);
        }

        public void DeleteMovie(Movie movie) {
            movieRepository.MakeTransient(movie);
        }

        public Movie GetMovieById(int id) {
            return movieRepository.Get(id);
        }

        public void UpdateMovie(Movie movie) {
            movieRepository.UpdateChange(movie);
        }

        public IList<Movie> GetAllMovie() {
            return movieRepository.GetAllMovies();
        }

        public IList<Categoria> GetAllCategorias() {
            return this.categoriaService.GetAllCategorias();
        }

        public Categoria GetCategoriaById(int id) {

            return this.categoriaService.GetById(id);
        }

        #endregion
    }
}
